package com.stone.bypass.proxy.core.anno;

import java.util.Set;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;

/**
 * @Auther: stone
 * @Date: 2021/3/7 17:17
 * @Description:
 */
public class ClassPathScanner extends ClassPathBeanDefinitionScanner {


  public ClassPathScanner(
      BeanDefinitionRegistry registry) {
    super(registry, false);
  }

  @Override
  public Set<BeanDefinitionHolder> doScan(String... basePackages) {
    return super.doScan(basePackages);
  }

  @Override
  protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
    return beanDefinition.getMetadata().isInterface() && beanDefinition.getMetadata().isIndependent();
  }

  /**
   * {@inheritDoc}
   */
  @Override
  protected boolean checkCandidate(String beanName, BeanDefinition beanDefinition) {
    return super.checkCandidate(beanName, beanDefinition);
  }
}
